#ifndef _TD_SDLMUSIC_H_
#define _TD_SDLMUSIC_H_

/************************************************************************/
/* STL                                                                  */
/************************************************************************/
#include <string>

/************************************************************************/
/* SDL                                                                  */
/************************************************************************/
#include "SDL/SDL.h"
#include "SDL/SDL_mixer.h" 

/************************************************************************/
/* Resources                                                            */
/************************************************************************/
#include "Resources/Resource.h"

using namespace std;

namespace TD_Resources {

	class SDLMusic : public Resource {

		Mix_Music *m_pMusic;

		static bool m_mixerInitialized;
		int m_channel;

	public:

		/************************************************************************/
		/* ctors and dtors					                                    */
		/************************************************************************/
		//Default constructor
		explicit SDLMusic();

		//Copy constructor
		explicit SDLMusic(const SDLMusic &rhs);

		//Assignment constructor
		SDLMusic& operator=(const SDLMusic &rhs);


		//Init constructor
		explicit SDLMusic(const string &musicName);
		//Destructor
		~SDLMusic();

		/************************************************************************/
		/* Functionalities                                                      */
		/************************************************************************/
		/**Loads a music from a file*/
		bool loadFile(const string &file);

		/**Plays the music loaded.*/
		void playMusic(bool loopMusic);
		
		/** Initializes the soundMixer */
		static void initSoundMixer();

		inline bool isPlaying() const {
			if(Mix_PlayingMusic() == 0)
				return false;
			return true;
		}

		inline void stopMusic() {
			Mix_HaltMusic();
		}

		inline void pauseMusic() {
			Mix_PauseMusic();
		}
		inline void resumeMusic() {
			Mix_ResumeMusic();
		}
	};
}

#endif